<template>
  <div>
    <FormPanel ref="from" :list="formList" @formChange="changeHandle" :isSubmitBtn="false" :collapse="false" labelWidth="110" />

    <div style="height:47px;"></div>

    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <el-button @click="closeDrawer(1)">关 闭</el-button>
    </div>
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import { getDetail, updatePlateApply, getDealerUser } from '@/api/omSale/Registration/RegistrationAudit';
export default {
  data() {
    this.saveData = null;
    return {
      formList: this.createdFrom()
    };
  },
  props: ['rowData'],
  created() {
    this.getUser();
    this.getDetail(this.rowData);
  },
  mixins: [dictionary],
  components: {},
  methods: {
    createdFrom() {
      return [
        {
          type: 'BREAK_SPACE',
          label: '车辆信息'
        },
        {
          type: 'INPUT',
          label: '车系名称',
          fieldName: 'seriesName',
          placeholder: '请输入',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '车型名称',
          fieldName: 'modelName',
          placeholder: '请输入',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '配置名称',
          fieldName: 'packageName',
          placeholder: '请输入',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '选装名称',
          fieldName: 'optionName',
          placeholder: '请输入',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '内饰',
          fieldName: 'trimName',
          placeholder: '请输入',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '外色',
          fieldName: 'colorName',
          placeholder: '请输入',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '产品名称',
          fieldName: 'productName',
          disabled: true,
          placeholder: '请输入',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '产品代码',
          fieldName: 'productCode',
          disabled: true,
          placeholder: '请输入',
          unitRender: () => {
            return (
              <div>
                <el-button icon="el-icon-search" onClick={() => this.seacherFun()}></el-button>
              </div>
            );
          }
        },
        {
          type: 'INPUT',
          label: '销售指导价',
          fieldName: 'salesQuatation',
          disabled: true,
          placeholder: '请输入'
        },
        {
          type: 'INPUT',
          label: 'VIN',
          fieldName: 'vin',
          placeholder: '请输入',
          disabled: true,
          unitRender: () => {
            return (
              <div>
                <el-button icon="el-icon-search" onClick={() => this.seacherFun()}></el-button>
              </div>
            );
          },
          rules: [{ required: true, message: '请选择', trigger: 'blur' }]
        },
        {
          type: 'INPUT',
          label: '发动机号',
          fieldName: 'engineNo',
          disabled: true,
          placeholder: '请输入'
        },
        {
          type: 'INPUT',
          label: '电机号',
          fieldName: 'motorNo',
          disabled: true,
          placeholder: '请输入'
        },
        {
          type: 'INPUT',
          label: '合格证号',
          fieldName: 'certificateCoverNo',
          disabled: true,
          placeholder: '请输入'
        },
        {
          type: 'INPUT',
          label: '电池号',
          fieldName: 'batteryNo',
          disabled: true,
          placeholder: '请输入'
        },
        {
          type: 'DATE',
          label: '配车日期',
          fieldName: 'distributionDate',
          placeholder: '请选择',
          disabled: true,
          dateType: 'exactdate'
        },
        {
          type: 'INPUT',
          label: '公告号',
          fieldName: 'announceNo',
          disabled: true,
          placeholder: '请输入'
        },
        {
          type: 'INPUT',
          label: '经销商',
          fieldName: 'dealerName',
          disabled: true,
          placeholder: '请输入'
        },
        {
          type: 'DATE',
          label: '出库日期',
          fieldName: 'productDate',
          disabled: true,
          placeholder: '请选择',
          dateType: 'exactdate'
        },
        {
          type: 'BREAK_SPACE',
          label: '客户信息'
        },

        {
          type: 'INPUT',
          label: '零售单号',
          fieldName: 'retailOrderNo',
          disabled: true,
          placeholder: '请输入',
          rules: [{ required: true, message: '请选择', trigger: 'blur' }],
          unitRender: () => {
            return (
              <div>
                <el-button icon="el-icon-search" onClick={() => this.seacherFun()}></el-button>
              </div>
            );
          }
        },
        {
          type: 'INPUT',
          label: '客户编号',
          fieldName: 'potentialCustomerNo',
          disabled: true,
          placeholder: '请输入',
          unitRender: () => {
            return (
              <div>
                <el-button icon="el-icon-search" onClick={() => this.seacherFun()}></el-button>
              </div>
            );
          }
        },
        {
          type: 'INPUT',
          label: '客户名称',
          fieldName: 'customerName',
          disabled: true,
          placeholder: '请输入'
        },
        {
          type: 'SELECT',
          label: '客户类型',
          fieldName: 'customerType',
          disabled: true,
          placeholder: '请选择',
          itemList: this.createDictList('1523'),
          rules: [{ required: true, message: '请选择', trigger: 'change' }]
        },
        {
          type: 'SELECT',
          label: '性别',
          fieldName: 'customerSex',
          disabled: true,
          placeholder: '请选择',
          itemList: this.createDictList('1002'),
          rules: [{ required: true, message: '请选择', trigger: 'change' }]
        },
        {
          type: 'DATE',
          label: '出生日期',
          fieldName: 'birthday',
          disabled: true,
          placeholder: '请输入',
          dateType: 'exactdate'
        },
        {
          type: 'SELECT',
          label: '年龄',
          fieldName: 'age',
          placeholder: '请选择',
          disabled: true,
          itemList: this.createDictList('9407')
        },
        {
          type: 'INPUT',
          label: '手机号',
          fieldName: 'mobile',
          disabled: true,
          placeholder: '请输入',
          rules: [{ required: true, message: '请输入', trigger: 'blur' }]
        },
        {
          type: 'INPUT',
          label: '电话',
          fieldName: 'mobile',
          disabled: true,
          placeholder: '请输入'
        },
        {
          type: 'SELECT',
          label: '证件类型',
          fieldName: 'carType',
          disabled: true,
          placeholder: '请选择',
          itemList: this.createDictList('1508')
        },
        {
          type: 'INPUT',
          label: '证件号',
          fieldName: 'cardNo',
          disabled: true,
          placeholder: '请输入'
        },
        {
          type: 'INPUT',
          label: '微信号',
          fieldName: 'wechatNo',
          disabled: true,
          placeholder: '请输入'
        },
        {
          type: 'SELECT',
          label: '省份',
          fieldName: 'provinceId',
          disabled: true,
          placeholder: '请选择',
          itemList: this.createRegionsList(),
          rules: [{ required: true, message: '请选择', trigger: 'blur' }]
        },
        {
          type: 'SELECT',
          label: '城市',
          fieldName: 'cityId',
          disabled: true,
          placeholder: '请选择',
          itemList: [],
          rules: [{ required: true, message: '请选择', trigger: 'blur' }]
        },
        {
          type: 'SELECT',
          label: '县区',
          fieldName: 'districtId',
          disabled: true,
          placeholder: '请选择',
          itemList: [],
          rules: [{ required: true, message: '请选择', trigger: 'blur' }]
        },
        {
          type: 'TEXT_AREA',
          label: '联系地址',
          fieldName: 'linkAddress',
          placeholder: '请输入',
          disabled: true,
          selfCols: 3
        },
        {
          type: 'INPUT',
          label: '邮编',
          fieldName: 'zipCode',
          disabled: true,
          placeholder: '请输入'
        },
        {
          type: 'SELECT',
          label: '职业',
          fieldName: 'occupation',
          disabled: true,
          placeholder: '请选择',
          itemList: this.createDictList('1527')
        },
        {
          type: 'SELECT',
          label: '学历',
          fieldName: 'education',
          disabled: true,
          placeholder: '请选择',
          itemList: this.createDictList('4049')
        },
        {
          type: 'SELECT',
          label: '户口类型',
          fieldName: 'residenceType',
          disabled: true,
          placeholder: '请选择',
          itemList: this.createDictList('7062')
        },
        {
          type: 'SELECT',
          label: '单位性质',
          fieldName: 'unitProperty',
          disabled: true,
          placeholder: '请选择',
          itemList: this.createDictList('7029')
        },
        {
          type: 'SELECT',
          label: '行业类型',
          fieldName: 'industryType',
          disabled: true,
          placeholder: '请选择',
          itemList: this.createDictList('7030')
        },
        {
          type: 'SELECT',
          label: '客户级别',
          fieldName: 'customerLevel',
          disabled: true,
          placeholder: '请选择',
          itemList: this.createDictList('1519')
        },
        {
          type: 'SELECT',
          label: '婚姻状况',
          fieldName: 'maritalStatus',
          disabled: true,
          placeholder: '请选择',
          itemList: this.createDictList('7028')
        },
        {
          type: 'SELECT',
          label: '家庭年收入',
          fieldName: 'annualFamilyIncome',
          disabled: true,
          placeholder: '请选择',
          itemList: this.createDictList('1290')
        },
        {
          type: 'SELECT',
          label: '兴趣爱好',
          fieldName: 'hobby',
          disabled: true,
          placeholder: '请选择',
          itemList: this.createDictList('9135')
        },
        {
          type: 'SELECT',
          label: '习惯联系方式',
          fieldName: 'contactDetails',
          disabled: true,
          itemList: this.createDictList('1532')
        },
        {
          type: 'INPUT',
          label: '习惯联系方式',
          fieldName: 'contactDetails',
          disabled: true,
          placeholder: '请输入'
        },
        {
          type: 'SELECT',
          label: '方便联系时段',
          fieldName: 'convenientContactTime',
          placeholder: '请选择',
          itemList: this.createDictList('9122')
        },
        {
          type: 'INPUT',
          label: '使用人',
          fieldName: 'userName',
          disabled: true,
          placeholder: '请输入'
        },
        {
          type: 'INPUT',
          label: '使用人电话',
          fieldName: 'userPhone',
          disabled: true,
          placeholder: '请输入'
        },
        // {
        //   type: 'SELECT',
        //   label: '是否大客户',
        //   fieldName: 'isMajor',
        //   disabled: true,
        //   placeholder: '请选择',
        //   itemList: this.createDictList('1004')
        // },

        {
          type: 'BREAK_SPACE',
          label: '销售信息'
        },
        {
          type: 'SELECT',
          label: '购车用途',
          fieldName: 'buyPurpose',
          disabled: true,
          placeholder: '请选择',
          itemList: this.createDictList('4536'),
          rules: [{ required: true, message: '请选择', trigger: 'change' }]
        },
        {
          type: 'INPUT',
          label: '销售顾问',
          fieldName: 'salesManName',
          disabled: true,
          placeholder: '请选择'
        },
        {
          type: 'INPUT',
          label: '购车价格',
          fieldName: 'buyPrice',
          disabled: true,
          placeholder: '请输入',
          rules: [{ required: true, message: '请输入', trigger: 'blur' }]
        },
        {
          type: 'SELECT',
          label: '支付方式',
          fieldName: 'payType',
          disabled: true,
          placeholder: '请选择',
          itemList: this.createDictList('6015'),
          rules: [{ required: true, message: '请选择', trigger: 'change' }]
        },
        {
          type: 'SELECT',
          label: '金融机构',
          fieldName: 'financialInstitution',
          disabled: true,
          placeholder: '请选择',
          itemList: this.createDictList('9602')
        },
        {
          type: 'SELECT',
          label: '期数',
          fieldName: 'periodsNumber',
          disabled: true,
          placeholder: '请选择',
          itemList: this.createDictList('6061')
        },
        {
          type: 'DATE',
          label: '交车日期',
          fieldName: 'deliveryDate',
          disabled: true,
          placeholder: '请选择',
          dateType: 'exactdate',
          rules: [{ required: true, message: '请选择', trigger: 'change' }]
        },
        {
          type: 'DATE',
          label: '开票日期',
          fieldName: 'invoiceDate',
          disabled: true,
          placeholder: '请选择',
          dateType: 'exactdate',
          rules: [{ required: true, message: '请选择', trigger: 'change' }]
        },
        {
          type: 'INPUT',
          label: '发票号',
          fieldName: 'invoiceNo',
          disabled: true,
          placeholder: '请输入'
        },
        {
          type: 'INPUT',
          label: '开票金额',
          fieldName: 'invoiceAmount',
          disabled: true,
          placeholder: '请输入',
          rules: [{ required: true, message: '请输入', trigger: 'blur' }]
        },
        {
          type: 'UPLOAD_FILE',
          label: '发票附件',
          fieldName: 'fpfj',
          placeholder: '请选择',
          initialValue: [],
          offsetRightCols: 1,
          disabled: true
        },
        {
          type: 'INPUT',
          label: '车牌号',
          fieldName: 'plateNumber',
          disabled: true,
          placeholder: '请输入',
          rules: [{ required: true, message: '请输入', trigger: 'blur' }]
        },
        {
          type: 'DATE',
          label: '上牌日期',
          fieldName: 'plateDate',
          disabled: true,
          placeholder: '请选择',
          dateType: 'exactdate'
        },
        {
          type: 'INPUT',
          label: '行驶证号',
          fieldName: 'drivingNo',
          disabled: true,
          placeholder: '请输入',
          rules: [{ required: true, message: '请输入', trigger: 'blur' }]
        },
        {
          type: 'DATE',
          label: '行驶证注册日期',
          fieldName: 'drivingRegisteDate',
          disabled: true,
          placeholder: '请选择',
          dateType: 'exactdate',
          rules: [{ required: true, message: '请选择', trigger: 'change' }]
        },
        {
          type: 'SELECT',
          label: '是否三包',
          fieldName: 'isThreeGuarantees',
          disabled: true,
          placeholder: '请选择',
          itemList: this.createDictList('1004'),
          rules: [{ required: true, message: '请选择', trigger: 'change' }]
        },
        {
          type: 'SELECT',
          label: '是否异地购车',
          fieldName: 'isOffsite',
          disabled: true,
          placeholder: '请选择',
          itemList: this.createDictList('1004'),
          rules: [{ required: true, message: '请选择', trigger: 'change' }]
        },
        {
          type: 'SELECT',
          label: '是否二次购买',
          fieldName: 'isSecond',
          disabled: true,
          placeholder: '请选择',
          itemList: this.createDictList('1004')
        },
        {
          type: 'SELECT',
          label: '是否建设电桩',
          fieldName: 'isBuild',
          disabled: true,
          placeholder: '请选择',
          itemList: this.createDictList('1004')
        },
        {
          type: 'SELECT',
          label: '是否申报补贴',
          fieldName: 'isSubsidy',
          disabled: true,
          placeholder: '请选择',
          itemList: this.createDictList('1004')
        },
        {
          type: 'SELECT',
          label: '上牌省份',
          fieldName: 'plateProvince',
          disabled: true,
          placeholder: '请输入',
          itemList: [],
          rules: [{ required: true, message: '请选择', trigger: 'change' }]
        },
        {
          type: 'SELECT',
          label: '上牌城市',
          fieldName: 'plateCity',
          disabled: true,
          placeholder: '请输入',
          itemList: [],
          rules: [{ required: true, message: '请选择', trigger: 'change' }]
        },
        {
          type: 'SELECT',
          label: '车辆性质',
          fieldName: 'vehicleType',
          disabled: true,
          placeholder: '请选择',
          itemList: this.createDictList('4103')
        },
        {
          type: 'INPUT',
          label: '交车里程',
          fieldName: 'mileage',
          placeholder: '请输入',
          disabled: true
        },
        {
          type: 'UPLOAD_FILE',
          label: '行驶证附件',
          fieldName: 'xszfj',
          placeholder: '请选择',
          initialValue: [],
          disabled: true,
          rules: [{ required: true, message: '请选择', trigger: 'change' }]
        },

        {
          type: 'BREAK_SPACE',
          label: '其他信息'
        },
        {
          type: 'TEXT_AREA',
          label: '备注',
          fieldName: 'remark',
          placeholder: '请输入',
          selfCols: 2,
          disabled: true,
          offsetRightCols: 1
        },
        {
          type: 'UPLOAD_FILE',
          label: '其他附件',
          fieldName: 'qtfj',
          placeholder: '请选择',
          initialValue: [],
          disabled: true
        },
        {
          type: 'TEXT_AREA',
          label: '审批意见',
          fieldName: 'checkDesc',
          placeholder: '请输入',
          selfCols: 2,
          offsetRightCols: 1,
          disabled: true
        }
      ];
    },
    async getUser() {
      let res = await getDealerUser();
      let empList = res.data.map(x => ({ text: x.employeeName, value: x.userId }));
      // this.formList.find(item => item.fieldName === 'salesMan').itemList = empList; //操作姓名
    },
    async getDetail(data) {
      let res = await getDetail({ applyId: data.applyId });
      for (let i in res.data) {
        this.formList.map(x => {
          if (x.fieldName == 'fpfj') {
            let arr = [];
            res.data.enclosures.map(y => {
              if (y.enclosureType == 'invoiceAddress') {
                arr.push({ name: y.enclosureName, url: y.enclosureUrl });
              }
            });
            x.initialValue = arr;
          } else if (x.fieldName == 'xszfj') {
            let arr = [];
            res.data.enclosures.map(y => {
              if (y.enclosureType == 'drivingAddress') {
                arr.push({ name: y.enclosureName, url: y.enclosureUrl });
              }
            });
            x.initialValue = arr;
          } else if (x.fieldName == 'qtfj') {
            let arr = [];
            res.data.enclosures.map(y => {
              if (y.enclosureType == 'otherAddress') {
                arr.push({ name: y.enclosureName, url: y.enclosureUrl });
              }
            });
            x.initialValue = arr;
          } else if (i == x.fieldName) {
            x.initialValue = res.data[i];
          }
        });
      }
      this.formList.find(x => x.fieldName == 'plateProvince').itemList = this.createRegionsList();
      this.formList.find(x => x.fieldName == 'plateCity').itemList = this.createcityList(res.data.plateProvince);
      this.formList.find(x => x.fieldName == 'cityId').itemList = this.createcityList(res.data.provinceId);
      this.formList.find(x => x.fieldName == 'districtId').itemList = this.district(res.data.cityId);
      console.log(res.data);
    },
    seacherFun() {},
    changeHandle(val) {},
    async closeDrawer(type) {
      this.$emit('close');
    }
  }
};
</script>
